<template>
    <div class="Layout">
        <el-container style="height: 500px; border: 1px solid #EEEEEE" v-loading.fullscreen.lock="$store.state.pageLoading">
            <el-aside width="210px" style="background-color: rgb(238, 241, 246)">
                <div class="logo">
                    <img src="@/assets/logo2.png" alt="">
                </div>
                <el-menu router
                         unique-opened
                         active-text-color="#FF7A63"
                         :default-active="active">
                    <el-menu-item index="/dashboard">
                        <img src="@/assets/aside-menu/aside-menu-1.png" alt="">
                        <span slot="title">工作台</span>
                    </el-menu-item>
                    <el-submenu index="2">
                        <template slot="title">
                            <img src="@/assets/aside-menu/aside-menu-2.png" alt="">
                            <span>基础数据管理</span>
                        </template>
                        <el-menu-item index="/data-management/organization">机构管理</el-menu-item>
                        <el-menu-item index="/data-management/work-scope">机构作业范围</el-menu-item>
                        <el-menu-item index="/data-management/freight">运费管理</el-menu-item>
                    </el-submenu>
                    <el-submenu index="3">
                        <template slot="title">
                            <img src="@/assets/aside-menu/aside-menu-3.png" alt="">
                            <span>车辆管理</span>
                        </template>
                        <el-menu-item index="/car-management/model">车型管理</el-menu-item>
                        <el-menu-item index="/car-management/list">车辆列表</el-menu-item>
                        <el-menu-item index="/car-management/register">回车登记</el-menu-item>
                    </el-submenu>
                    <el-submenu index="4">
                        <template slot="title">
                            <img src="@/assets/aside-menu/aside-menu-4.png" alt="">
                            <span>员工管理</span>
                        </template>
                        <el-menu-item index="4-1">快递员管理</el-menu-item>
                        <el-menu-item index="4-2">司机管理</el-menu-item>
                        <el-menu-item index="4-3">排班管理</el-menu-item>
                    </el-submenu>
                    <el-submenu index="5">
                        <template slot="title">
                            <img src="@/assets/aside-menu/aside-menu-5.png" alt="">
                            <span>业务管理</span>
                        </template>
                        <el-menu-item index="5-1">订单管理</el-menu-item>
                        <el-menu-item index="5-2">运单管理</el-menu-item>
                    </el-submenu>
                    <el-submenu index="6">
                        <template slot="title">
                            <img src="@/assets/aside-menu/aside-menu-6.png" alt="">
                            <span>调度管理</span>
                        </template>
                        <el-menu-item index="6-1">运输任务管理</el-menu-item>
                        <el-menu-item index="6-2">线路管理</el-menu-item>
                        <el-menu-item index="6-3">取件作业管理</el-menu-item>
                        <el-menu-item index="6-4">派件作业管理</el-menu-item>
                    </el-submenu>
                </el-menu>
            </el-aside>

            <el-container>
                <el-header style="text-align: right; font-size: 12px" height="56px">
                    <div class="left">
                        <i class="el-icon-back" @click="$router.back()"><span>返回</span></i>
                        <el-divider direction="vertical"></el-divider>
                        <h3 class="title">{{ title }}</h3>
                    </div>
                    <div class="user">
                        <img src="@/assets/avatar.jpg" alt="">
                        <span class="name">{{ userInfo.name }}</span>
                        <el-divider direction="vertical"></el-divider>
                        <el-popover
                            placement="top"
                            width="160"
                            v-model="visible">
                            <p>确定要退出登录吗？</p>
                            <div style="text-align: right; margin: 0">
                                <el-button size="mini" type="text" @click="visible = false">取消</el-button>
                                <el-button type="primary" size="mini" @click="logout">确定</el-button>
                            </div>
                            <img slot="reference" src="@/assets/logout.png" alt="">
                        </el-popover>
                    </div>
                </el-header>
<span id="d1"></span>
                <div class="main">
                    <Transition name="fade" mode="out-in">
                        <router-view></router-view>
                    </Transition>
                </div>

                <el-footer height="56px">
                    <span>江苏传智播客教育科技股份有限公司</span>
                    <span>版权所有Copyright 2006-2022 All Rights Reserved</span>
                    <span>苏ICP备16007882号-11</span>
                </el-footer>
            </el-container>
        </el-container>
    </div>
</template>

<script>
import { delToken } from '@/utils/storage'
import { getMenus, getWorkSpace } from '@/api/dashboard'
import { mapState } from 'vuex'
import { Message } from 'element-ui'
import dayjs from 'dayjs'

export default {
    name: 'LayoutPage',
    created () {
        this.active = this.$route.path
        this.title = this.$route.name
        this.userInfo = this.$store.state.user.userInfo
    },
    data () {
        return {
            visible: false,
            active: '',
            title: '',
            userInfo: {}
        }
    },
    methods: {
        logout () {
            delToken()
            this.$router.push('/login')
        }
    },
    watch: {
        $route() {
            this.title = this.$route.name
        }
    }
}
</script>
<style>
.fade-enter-active,
.fade-leave-active {
    transition: all 0.5s ease;
}

.fade-leave {
    transform: translate(0, 0);
}

.fade-leave-to {
    opacity: 0;
    transform: translate(20px, 0);
}

.fade-enter {
    opacity: 0;
    transform: translate(-20px, 0);
}

.fade-enter-to {
    transform: translate(0, 0);
}
</style>
<style scoped lang="scss">
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

::-webkit-scrollbar {
    display: none;
}

.Layout {
    > .el-container {
        height: 100vh !important;
    }

    .el-aside {
        color: #262335;
        background-color: white !important;

        .logo {
            text-align: center;
            padding: 20px 20px 0px;

            img {
                width: 152px;
            }
        }

        ::v-deep .el-menu {
            border: none;

            > .el-menu-item {
                padding-left: 25px !important;
            }

            > .el-submenu {
                .el-submenu__title {
                    padding-left: 25px !important;
                }

                .el-menu {
                    .el-menu-item {
                        padding-left: 60px !important;
                    }

                    .is-active {
                        background-color: #FCEEEB;
                    }
                }
            }

            .is-active.el-menu-item {
                background-color: #FCEEEB;
            }

            img {
                width: 16px;
                margin-right: 19px;
            }
        }
    }

    .is-vertical {
        .el-header {
            background-color: #F3F5F9;
            color: #2A2929;
            line-height: 56px;
            display: flex;
            justify-content: space-between;
            padding: 8px 26px 0;

            .left {
                display: flex;
                align-items: center;

                i {
                    font-size: 16px;
                    cursor: pointer;

                    span {
                        margin-left: 6px;
                    }
                }

                .el-divider {
                    margin: 0 16px;
                    height: 18px;
                }

                h3 {
                    font-size: 16px;
                    font-weight: bold;
                }
            }

            .user {
                display: flex;
                align-items: center;
                font-size: 14px;

                > img {
                    width: 30px;
                    border-radius: 15px;
                    margin-right: 12px;
                }

                .el-divider {
                    height: 18px;
                    margin: 0 18px;
                }

                .el-popover__reference-wrapper {
                    img {
                        width: 18px;
                        margin-top: 22px;
                        cursor: pointer;
                    }
                }
            }
        }

        .main {
            background-color: #F3F4F7;
            width: 100%;
            height: 100%;
            padding: 0 12px;
            overflow: auto;
        }

        footer {
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #F3F4F7;

            span {
                color: #BAC0CD;
                font-size: 14px;
                margin: 0 10px;
            }
        }
    }
}
</style>

<style>
.el-button--mini {
    padding: 5px 6px;
    margin-top: 10px;
}
</style>
